package com.threeti.jiayusms.interfaces;

import static org.apache.commons.lang.StringUtils.isEmpty;
import static org.apache.commons.lang.StringUtils.isNotEmpty;

import com.threeti.jiayusms.framework.util.DynaSearchCriteria;

public class FunctionTemplateDynaCriteriaDto implements DynaSearchCriteria {
  private String functionTemplateId;
  private String functionName;
  private String functionType;

  private String relationTable;
  private String relationField;
  private String associatedField;
  private String functionContent;
  
  @Override
  public FunctionTemplateDynaCriteriaDto postInit() {
    if (isEmpty(functionType)) {//所有的函数类型
      relationTable = "";
      relationField = "";
      associatedField = "";
      functionContent = "";
    } else if (functionType.equals("0")){//数据函数
      functionContent = "";
      if (isEmpty(relationTable)) {//所有对应表
        relationField = "";
        associatedField = "";
        
        //TODO 对应表再下层的无条件检索
      }
    } else {//系统函数
      relationTable = "";
      relationField = "";
      associatedField = "";
    }
    
    return this;
  }

  public String getFunctionTemplateId() {
    return functionTemplateId;
  }
  
  public String getFunctionName() {
    return functionName;
  }

  public String getFunctionType() {
    return functionType;
  }

  public String getRelationTable() {
    return relationTable;
  }

  public String getRelationField() {
    return relationField;
  }

  public String getAssociatedField() {
    return associatedField;
  }

  public String getFunctionContent() {
    return functionContent;
  }

  @Override
  public boolean isAnyConditionInput() {
    return isNotEmpty(functionTemplateId) || isNotEmpty(functionName) || isNotEmpty(functionType)
          || isNotEmpty(relationTable) || isNotEmpty(relationField) || isNotEmpty(associatedField) || isNotEmpty(functionContent);
  }
  
}
